package top.ffhome.concurrent.beautiful.ch01;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

public class Demo3Test {
    private static final Log log = LogFactory.get();

    public static void main(String[] args) throws InterruptedException {
        Thread threadOne = new Thread(() -> {
            log.info("threadOne begin run!");
            for (; ; ) {
            }
        });

        final Thread mainThread = Thread.currentThread();

        Thread threadTwo = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                log.error(e);
            }
            mainThread.interrupt();
        });

        threadOne.start();
        threadTwo.start();
        try {
            threadOne.join();
        } catch (InterruptedException e) {
            log.info("main thread:", e);
        }
    }
}
